package com.naiterui.ehp.bs.doctor.dao.impl;

import com.naiterui.ehp.bp.domain.NoticeTopic;
import com.naiterui.ehp.bs.doctor.dao.INoticeTopicDao;
import com.naiterui.ehp.bs.doctor.repository.INoticeTopicRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository
public class AdNoticeTopicDaoImpl  implements INoticeTopicDao {

    @Autowired
    private INoticeTopicRepository noticeTopicRepository;

    @Override
    public NoticeTopic get(Long id) {
        return noticeTopicRepository.get(id);
    }

    /*
     * 获取公告主题 map
     * INoticeTopicDao.getTopicMap()
     */
    @Override
    public Map<Long, NoticeTopic> getTopicMap() {

        Map<Long, NoticeTopic> resultMap = new HashMap<>();
        Iterable<NoticeTopic> noticeList = noticeTopicRepository.findAll();
        if (null != noticeList ) {
            for (NoticeTopic noticeTopic : noticeList) {
                resultMap.put(noticeTopic.getId(), noticeTopic);
            }
        }
        return resultMap;
    }

}
